**********************************************************************************************
* Generates Table 1
*
* Cloyne, Dimsdale and Hürtgen (2024) 								
*	"Are Tax Cuts Contractionary at the Zero Lower Bound? Evidence from a Century of Data"  	  		
*																			
* James Cloyne, Nicholas Dimsdale and Patrick Hürtgen, 2024
**********************************************************************************************

global projectdir "CDHReplicationPackage"

cd "${projectdir}"
global dofilepath = "DoFiles"
global datapath = "MainData"
local shockpath = "NarrativeShocks"

* load shock series 
global DataSetName = "MacroData_LRConsistentShocks"

cap log close
log using "${projectdir}/Tables/GrangerSummary_Small.log", replace
*log using "GrangerSummary_Small.log", replace

global TaxShocks_X X_TaxToGDP
global TaxShocks_N N_TaxToGDP

use ${datapath}/${DataSetName}, clear

drop if inrange(Date,tq(1939q1),tq(1945q4))
drop if Date > tq(2019q4)
drop if Date < tq(1920q1)


**** Correlation of X and N *****

correl ${TaxShocks_X} ${TaxShocks_N} 

sum ${TaxShocks_X}

sum ${TaxShocks_X} if ${TaxShocks_X} ! = 0

sum ${TaxShocks_N}

sum ${TaxShocks_N} if ${TaxShocks_N} ! = 0


**** Number of lags to include in tests *****
local lags = 4

qui: var ${TaxShocks_X} d.lnRealGDP d.BankRate d.Unemployment d.lnCPISA d.lnRealExp, lags(1/`lags')  dfk small

vargranger

matrix vals = r(gstats)
scalar F_X_ALL = vals[6,1]
scalar p_X_ALL = vals[6,4]

qui: var ${TaxShocks_N} d.lnRealGDP d.BankRate d.Unemployment d.lnCPISA d.lnRealExp, lags(1/`lags')  dfk small

vargranger

matrix vals = r(gstats)
scalar F_N_ALL = vals[6,1]
scalar p_N_ALL = vals[6,4]

capture		file close myfile

file 		open myfile using "${projectdir}/Tables/Table1.tex", write replace
file		write myfile "\begin{tabular}{p{5cm} >{\centering\arraybackslash}p{1.8cm} >{\centering\arraybackslash}p{1.8cm}}\toprule" _n
file		write myfile "\toprule" _n
file		write myfile "Series & Test statistic & p-value  \\ " _n
file		write myfile "\midrule" _n

file		write myfile "	\textit{Exogenous series} & &  \\ " _n
file		write myfile "				\hspace{.5cm} Exogenous tax changes &" %6.2f (scalar(F_X_ALL)) 
file		write myfile "&" %6.2f (scalar(p_X_ALL))
file		write myfile "\\ " _n

file		write myfile "			& & \\ " _n

file		write myfile "				\textit{Endogenous series} & &  \\ " _n
file		write myfile "				\hspace{.5cm} Endogenous tax changes &" %6.2f (scalar(F_N_ALL)) 
file		write myfile "&" %6.2f (scalar(p_N_ALL))
file		write myfile "\\ " _n

file		write myfile " \bottomrule " _n
file		write myfile " \end{tabular}" _n
file		close myfile

cap log close
